package ducky.servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class HelloWorld
 */
/*@WebServlet("/ducky")*/
public class HelloWorld extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public HelloWorld() {
        super();
        // TODO Auto-generated constructor stub
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		ServletContext context = this.getServletContext();
		String account = context.getInitParameter("account");
		String password = context.getInitParameter("pass");
		ServletConfig config = this.getServletConfig();
		String song = config.getInitParameter("song");
		PrintWriter writer = response.getWriter();
		writer.println("Hello World By Post </br>");
		writer.println("This is song "+song);
		writer.println("account: "+account+ " has password: "+password);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		ServletContext context = this.getServletContext();
		String account = context.getInitParameter("account");
		String password = context.getInitParameter("pass");
		ServletConfig config = this.getServletConfig();
		String song = config.getInitParameter("song");
		PrintWriter writer = response.getWriter();
		writer.println("Hello World By Post </br>");
		writer.println("This is song "+song);
		writer.println("account: "+account+ " has password: "+password);
	}

}
